package com.jz.community.basecomm.utils;

import android.graphics.drawable.Drawable;

import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;

import java.io.File;

public class ImageDownloadTarget extends SimpleTarget<File> implements
        GlideProgressSupport.ProgressListener {

    private final String mUrl;

    protected ImageDownloadTarget(String url) {
        mUrl = url;
    }

    @Override
    public void onResourceReady(File resource, Transition<? super File> transition) {
        GlideProgressSupport.forget(mUrl);
    }

    @Override
    public void onLoadCleared(Drawable placeholder) {
        super.onLoadCleared(placeholder);
        GlideProgressSupport.forget(mUrl);
    }

    @Override
    public void onLoadStarted(Drawable placeholder) {
        super.onLoadStarted(placeholder);
        GlideProgressSupport.expect(mUrl, this);
    }

    @Override
    public void onLoadFailed(Drawable errorDrawable) {
        super.onLoadFailed(errorDrawable);
        GlideProgressSupport.forget(mUrl);
    }

    @Override
    public void onDownloadStart() {

    }

    @Override
    public void onProgress(int progress) {

    }

    @Override
    public void onDownloadFinish() {

    }
}
